<template>
	<div>
		<el-dialog :title="$t('action.update')" width="70%" class="icon-dialog" :visible.sync="show" @open="open" :before-close="closeForm" append-to-body>
			<el-form :size="size" ref="form" :model="form" :rules="rules" :label-width="$store.getters.device !== 'mobile'?'16%':'90px'">
 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FMATERIALID')" prop="FMATERIALID">
							<el-input v-model="form.FMATERIALID" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FMATERIALID')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FNUMBER')" prop="FNUMBER">
							<el-input v-model="form.FNUMBER" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FNUMBER')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FOLDNUMBER')" prop="FOLDNUMBER">
							<el-input v-model="form.FOLDNUMBER" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FOLDNUMBER')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FSPECIFICATION')" prop="FSPECIFICATION">
							<el-input v-model="form.FSPECIFICATION" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FSPECIFICATION')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FMATERIALGROUP')" prop="FMATERIALGROUP">
							<el-input v-model="form.FMATERIALGROUP" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FMATERIALGROUP')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FCREATEORG')" prop="FCREATEORG">
							<el-input v-model="form.FCREATEORG" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FCREATEORG')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FUSEORG')" prop="FUSEORG">
							<el-input v-model="form.FUSEORG" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FUSEORG')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FCREATEDATE')" prop="FCREATEDATE">
							<el-input v-model="form.FCREATEDATE" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FCREATEDATE')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FMODIFIER')" prop="FMODIFIER">
							<el-input v-model="form.FMODIFIER" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FMODIFIER')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FMODIFYDATE')" prop="FMODIFYDATE">
							<el-input v-model="form.FMODIFYDATE" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FMODIFYDATE')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FSTATUS')" prop="FSTATUS">
							<el-input v-model="form.FSTATUS" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FSTATUS')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FFORBIDSTATUS')" prop="FFORBIDSTATUS">
							<el-input v-model="form.FFORBIDSTATUS" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FFORBIDSTATUS')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FAPPROVER')" prop="FAPPROVER">
							<el-input v-model="form.FAPPROVER" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FAPPROVER')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FAPPROVEDATE')" prop="FAPPROVEDATE">
							<el-input v-model="form.FAPPROVEDATE" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FAPPROVEDATE')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FFORBIDDER')" prop="FFORBIDDER">
							<el-input v-model="form.FFORBIDDER" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FFORBIDDER')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FFORBIDDATE')" prop="FFORBIDDATE">
							<el-input v-model="form.FFORBIDDATE" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FFORBIDDATE')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FCountType')" prop="FCountType">
							<el-input v-model="form.FCountType" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FCountType')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FQualityInstock')" prop="FQualityInstock">
							<el-input v-model="form.FQualityInstock" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FQualityInstock')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FCoefficient')" prop="FCoefficient">
							<el-input v-model="form.FCoefficient" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FCoefficient')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FCREATEUSERNAME')" prop="FCREATEUSERNAME">
							<el-input v-model="form.FCREATEUSERNAME" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FCREATEUSERNAME')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Material_FName')" prop="FName">
							<el-input v-model="form.FName" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Material_FName')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
				</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button :size="size" :loading="loading" type="primary" @click="submit" >
					<span v-if="!loading">{{$t('system.confirm')}}</span>
					<span v-else>{{$t('system.submitting')}}</span>
				</el-button>
				<el-button :size="size" @click="closeForm">{{$t('system.cancel')}}</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
import { update } from '@/api/app/material'

export default {
	name:'materialupdate',
	components: {
	},
	props: {
		show: {
			type: Boolean,
			default: false
		},
		size: {
			type: String,
			default: 'small'
		},
		info: {
			type: Object,
		},
	},
	data(){
		return {
		    dialog:{
			},
			form: {
			   FMATERIALID:'',
			   FNUMBER:'',
			   FOLDNUMBER:'',
			   FSPECIFICATION:'',
			   FMATERIALGROUP:'',
			   FCREATEORG:'',
			   FUSEORG:'',
			   FCREATEDATE:'',
			   FMODIFIER:'',
			   FMODIFYDATE:'',
			   FSTATUS:'',
			   FFORBIDSTATUS:'',
			   FAPPROVER:'',
			   FAPPROVEDATE:'',
			   FFORBIDDER:'',
			   FFORBIDDATE:'',
			   FCountType:'',
			   FQualityInstock:'',
			   FCoefficient:'',
			   FCREATEUSERNAME:'',
			   FName:'',
			},
		    initial:{},        
			loading:false,
			rules: {
			}
		}
	},
	watch:{
		show(val){
			if(val){
			}
		}
	},
	methods: {
		open(){
			this.form = this.info
		},
		submit(){
			this.$refs['form'].validate(valid => {
				if(valid) {
					this.loading = true
					update(this.form).then(res => {
						if(res.status == 200){
							this.$message({message: this.$t('system.success'), type: 'success'})
							this.$emit('refresh_list')
							this.closeForm()
						}
					}).catch(()=>{
						this.loading = false
					})
				}
			})
		},
		closeForm(){
			this.$emit('update:show', false)
			this.loading = false
			if (this.$refs['form']!==undefined) {
				this.$refs['form'].resetFields()
			}
		},
	}
}
</script>
<style scoped lang="scss">
@import '@/assets/scss/common.scss'
</style>
